<?php include("../../data/mysql.class.php")?>
<?php include("../../data/Function.php")?>
<?php
    if(isset($_POST["Type"])){
        $Type=$_POST["Type"];
    }else{
        $Type="error";
    }
	
	$conn=new Mysql();
	switch($Type){
		case "delete":
		if($conn->query("delete from guanli_table_shop where id =".$_POST["id"])){
			echo 1;
			}else{
				echo 0;
				}
		break;
		case "add":
		$attrtype=$_POST["attrtype"];
		$attr=$_POST["attr"];
		$pic=$_POST["pic"];
		$pmoney=$_POST["pmoney"];
		$istype=$_POST["istype"];
		$shopid=$_POST["shopid"];
		$pid=$_POST["pid"];
            if($conn->query("insert into d_attr(shopid,pid,attrtype,attr,pic,pmoney,px,istype) values($shopid,$pid,'$attrtype','$attr','$pic',$pmoney,0,'$istype')")){

                echo 1;}else{
                echo 0;
            }
		break;
		case "update":
		$user_name=$_POST["adminName"];
		$pwd1=$_POST["password1"];
		$pwd=$_POST["password2"];
		$Uname=$_POST["uname"];
		$phone=$_POST["phone"];	
		$guanli_gltype=$_POST["adminRole"];
            $areaid=$_POST["areaid"];
		$id=$_POST["id"];
		$conn=new Mysql();
		if($pwd!=""){$rspwd=substr(md5($pwd),8,16);}else{$rspwd=$pwd1;}	
		if($conn->query("update guanli_table_shop set guanli_name='$user_name',guanli_mima='$rspwd',guanli_gltype=$guanli_gltype,guanli_uname='$Uname',mobile='$phone',areaid=$areaid where id=".$id)){
					
				echo 1;}else{
					echo 0;
					}
		break;
		case "checkstate":
			if($conn->query("update  guanli_table_shop set isstate=".$_POST["isstate"]." where id =".$_POST["id"])){
			echo 1;
			}else{
				echo 0;
				}
		break;
		default:
		break;
		}
?>